<!-- src/views/DashboardView.vue -->
<template>
  <div class="dashboard-view">
    <div class="dashboard-header">
      <h2>系统概览</h2>
      <div class="current-time">
        当前时间：{{ currentTime }}
      </div>
    </div>

    <!-- 统计卡片 -->
    <div class="stats-grid">
      <div class="stat-card">
        <div class="stat-icon">👨‍🎓</div>
        <div class="stat-content">
          <h3>学生总数</h3>
          <p class="stat-number">1,254</p>
        </div>
      </div>
      
      <div class="stat-card">
        <div class="stat-icon">👨‍🏫</div>
        <div class="stat-content">
          <h3>教师总数</h3>
          <p class="stat-number">86</p>
        </div>
      </div>
      
      <div class="stat-card">
        <div class="stat-icon">📚</div>
        <div class="stat-content">
          <h3>课程总数</h3>
          <p class="stat-number">42</p>
        </div>
      </div>
      
      <div class="stat-card">
        <div class="stat-icon">📝</div>
        <div class="stat-content">
          <h3>本学期成绩</h3>
          <p class="stat-number">3,842</p>
        </div>
      </div>
    </div>

    <!-- 快速操作区域 -->
    <div class="quick-actions">
      <h3>快速操作</h3>
      <div class="action-buttons">
        <router-link to="/courses" class="action-btn">
          <span>📚</span>
          <span>课程管理</span>
        </router-link>
        <!-- <span>👨‍🎓</span> -->
      <router-link to="/users" class="action-btn">
          <span>👨‍🎓</span>
          <span>用户管理</span>
        </router-link>
        <button class="action-btn">
          <span>👨‍🏫</span>
          <span>教师管理</span>
        </button>
        <button class="action-btn">
          <span>📊</span>
          <span>成绩管理</span>
        </button>
      </div>
    </div>

    <!-- 最近活动 -->
    <div class="recent-activities">
      <h3>最近活动</h3>
      <div class="activity-list">
        <div class="activity-item">
          <div class="activity-icon">📝</div>
          <div class="activity-content">
            <p>张老师录入了一门新课程</p>
            <span class="activity-time">2小时前</span>
          </div>
        </div>
        <div class="activity-item">
          <div class="activity-icon">👨‍🎓</div>
          <div class="activity-content">
            <p>新增学生注册：李小明</p>
            <span class="activity-time">4小时前</span>
          </div>
        </div>
        <div class="activity-item">
          <div class="activity-icon">📊</div>
          <div class="activity-content">
            <p>系统自动备份完成</p>
            <span class="activity-time">昨天</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { ref, onMounted, onUnmounted } from 'vue';

export default {
  name: 'DashboardView',
  setup() {
    const currentTime = ref('');

    const updateTime = () => {
      currentTime.value = new Date().toLocaleString('zh-CN', {
        year: 'numeric',
        month: '2-digit',
        day: '2-digit',
        hour: '2-digit',
        minute: '2-digit',
        second: '2-digit'
      });
    };

    let timer;
    onMounted(() => {
      updateTime();
      timer = setInterval(updateTime, 1000);
    });

    onUnmounted(() => {
      if (timer) clearInterval(timer);
    });

    return {
      currentTime
    };
  }
};
</script>

<style scoped>
.dashboard-view {
  padding: 0;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.dashboard-header h2 {
  margin: 0;
  color: #2c3e50;
  font-size: 24px;
}

.current-time {
  color: #7f8c8d;
  font-size: 14px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.stat-card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  gap: 15px;
  transition: transform 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
}

.stat-icon {
  font-size: 40px;
}

.stat-content h3 {
  margin: 0 0 5px 0;
  color: #7f8c8d;
  font-size: 14px;
  font-weight: normal;
}

.stat-number {
  margin: 0;
  font-size: 24px;
  font-weight: bold;
  color: #2c3e50;
}

.quick-actions {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin-bottom: 30px;
}

.quick-actions h3 {
  margin: 0 0 15px 0;
  color: #2c3e50;
}

.action-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
}

.action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 15px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  text-decoration: none;
  color: #495057;
  transition: all 0.3s ease;
  cursor: pointer;
}

.action-btn:hover {
  background: #e9ecef;
  transform: translateY(-1px);
}

.action-btn span:first-child {
  font-size: 24px;
  margin-bottom: 5px;
}

.action-btn span:last-child {
  font-size: 14px;
  font-weight: 500;
}

.recent-activities {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.recent-activities h3 {
  margin: 0 0 15px 0;
  color: #2c3e50;
}

.activity-item {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f1f3f4;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  font-size: 20px;
  margin-right: 15px;
}

.activity-content p {
  margin: 0 0 5px 0;
  color: #2c3e50;
}

.activity-time {
  color: #7f8c8d;
  font-size: 12px;
}
</style>